function quickSortReform(arr,left,right){
    let mid = Math.floor((left+right)/2);
    let i = left;
    let j = right;
    while(i <= j){
        while(arr[i] < arr[mid]){
            i++;
        }
        while(arr[j] > arr[mid]){
            j--;
        }
        if (i <= j){
            let temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
            i++;
            j--;
        }
    }
    return i;
}

function quickSort(arr,left,right){
    if (right - left < 1){
        return arr;
    }
    let index = quickSortReform(arr,left,right);
    if (index - 1 >= left){
        quickSort(arr,left,index - 1);
    }
    if (index <= right){
        quickSort(arr,index,right)
    }
    return arr;
}

let arr = quickSort([2,3,4,12,3,213,123,45,665,76,9],0,10);
console.log(arr)